import wx

class BMI(wx.Frame):
    def __init__(self, *args, **kw):
        super(BMI, self).__init__(*args, **kw)
        self.panel = wx.Panel(self)
        #self.panel.SetBackgroundColour((255, 255, 255))
        self.text = wx.StaticText(self.panel, -1, label = "BMI calculator", pos = ((40, 10)))
        self.weight_label = wx.StaticText(self.panel, -1, label = "weight:", pos = ((40,50)))
        self.height_label = wx.StaticText(self.panel, -1, label = "height:", pos = ((40, 80)))
        self.add_weight = wx.SpinCtrl(self.panel, -1, pos = ((120, 50)), min = 5, max = 200, initial = 5)
        self.add_height = wx.SpinCtrl(self.panel, -1, pos = ((120, 80)), min = 50, max = 300, initial = 5)
        self.cmbtn = wx.Button(self.panel, label = "Compute", pos = ((40, 120)))
        self.clbtn = wx.Button(self.panel, label = "Close", pos = ((120, 120)))
        self.dark = False
        self.darkbtn = wx.ToggleButton(self.panel, label = "Dark Mode", pos = ((200, 120)))
        self.clbtn.Bind(wx.EVT_BUTTON, self.OnClose)
        self.cmbtn.Bind(wx.EVT_BUTTON, self.Compute)
        self.darkbtn.Bind(wx.EVT_TOGGLEBUTTON, self.ChangeColor)
        self.bmi = wx.StaticText(self.panel, -1, label = "... BMI index", pos = ((80, 150)))
    def OnClose(self, e):
        self.Close()

    def Compute(self, e):
        bmi_f = round((self.add_weight.GetValue() / (self.add_height.GetValue() * self.add_height.GetValue())) * 10000, 2)
        bmi_s = str(bmi_f) + " BMI index"
        self.bmi.SetLabel(bmi_s)

    def ChangeColor(self,e):
        #self.dark = not self.dark

        if not self.dark:
            self.text.SetForegroundColour((255,255,255))
            self.bmi.SetForegroundColour((255,255,255))
            self.weight_label.SetForegroundColour((255,255,255))
            self.height_label.SetForegroundColour((255,255,255))
            self.panel.SetBackgroundColour((0, 0, 0))
            self.panel.Refresh()
            self.dark = True
            #print("not dark")
        else:
            self.text.SetForegroundColour((0,0,0))
            self.bmi.SetForegroundColour((0,0,0))
            self.weight_label.SetForegroundColour((0,0,0))
            self.height_label.SetForegroundColour((0,0,0))
            self.panel.SetBackgroundColour((255,255,255))
            self.panel.Refresh()
            self.dark = False
            #print("dark")


    

app = wx.App()
frame = BMI(None)
frame.Show()
app.MainLoop()